// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

#ifndef PFM_OBSERVER_H_
#define PFM_OBSERVER_H_

#include "pfm.h"
#include "status/rot_status.h"


/**
 * Interface for notifying observers of PFM events.  Unwanted event notifications will be set to
 * null.
 */
struct pfm_observer {
	/**
	 * Notification that a new PFM has been verified and marked as pending.
	 *
	 * Arguments sent with this notification will not be null.
	 *
	 * @param observer The observer being notified.
	 * @param pending The PFM that passed verification and is pending.
	 */
	void (*on_pfm_verified) (struct pfm_observer *observer, struct pfm *pending);

	/**
	 * Notification that a new PFM has been made the active PFM.
	 *
	 * Arguments sent with this notification will not be null.
	 *
	 * @param observer The observer being notified.
	 * @param active The PFM that was activated.
	 */
	void (*on_pfm_activated) (struct pfm_observer *observer, struct pfm *active);

	/**
	 * Notification that the active PFM has been erased.
	 *
	 * @param observer The observer being notified.
	 */
	void (*on_clear_active) (struct pfm_observer *observer);
};


#define	PFM_OBSERVER_ERROR(code)		ROT_ERROR (ROT_MODULE_PFM_OBSERVER, code)

/**
 * Error codes that can be generated by a PFM observer.
 */
enum {
	PFM_OBSERVER_INVALID_ARGUMENT = PFM_OBSERVER_ERROR (0x00),				/**< Input parameter is null or not valid. */
	PFM_OBSERVER_NO_MEMORY = PFM_OBSERVER_ERROR (0x01),						/**< Memory allocation failed. */
	PFM_OBSERVER_MEASUREMENTS_NOT_UNIQUE = PFM_OBSERVER_ERROR (0x02),		/**< Measurement IDs are not unique */
};


#endif /* PFM_OBSERVER_H_ */
